package com.gyyx.plugins;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.unity3d.player.UnityPlayerActivity;
//import com.unity3d.player.UnityPlayerActivity;

/**
 * // Created by xuchang on 2019/12/4
 **/
public class UnityNotifyReceiver extends BroadcastReceiver {
    private static final String TAG = "UnityNotifyReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {

        //Log.d("Receive!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "��ʱ�ѽ��յ���Ϣ����������");
        Class<?> unityActivity = null;
        Intent activity;
        String mainActivityName = com.gyyx.plugins.ToolUtils.getActivities(context);
        /*try {
            if (mainActivityName != null) {
                unityActivity = context.getClassLoader().loadClass(mainActivityName);
            }

            *//*if (unityActivity == null) {
                activity = new Intent(context, UnityPlayerActivity.class);
            } else {
                activity = new Intent(context, unityActivity);
            }*//*
        } catch (Exception ex) {
            ex.printStackTrace();
            return;
        }*/
        activity = new Intent(context, UnityPlayerActivity.class);
        activity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, AndroidNotificator.m_nLastID, activity, PendingIntent.FLAG_UPDATE_CURRENT);
        AndroidNotificator.setInfoNotification(context, intent.getStringExtra("title"), intent.getStringExtra("content"), intent.getStringExtra("ticker"), pendingIntent);
    }
}
